home *** CD-ROM | disk | FTP | other *** search
- Path: prairienet.org!sjmccaug
- From: sjmccaug@prairienet.org (Scott J. McCaughrin)
- Newsgroups: comp.lang.c++
- Subject: Re: Copy constructor
- Date: 12 Apr 1996 01:27:18 GMT
- Organization: University of Illinois at Urbana
- Message-ID: <4kkbhm$mva@vixen.cso.uiuc.edu>
- References: <4kjudi$2qj0@holly.ACNS.ColoState.EDU>
- Reply-To: sjmccaug@prairienet.org (Scott J. McCaughrin)
- NNTP-Posting-Host: firefly.prairienet.org
-
-
- In a previous article, corbyh@holly.ACNS.ColoState.EDU (Corby S. Hudnall) says:
-
- >Hi all, I'm having some trouble figuring out how to do a copy
- >constructor. Here's what I thought was suppose to work:
- >
- >header file----
- >class ABC
- >{
- > private:
- > int AnInt;
- >
- > public:
- > ABC():AnInt(5) {} // Default Constructor
- > ~ABC() {} // Default Destructor
- > ABC(const ABC&); // Copy constructor
- >}
- >
- >ABC::ABC(const ABC& NewABC)
- >{
- > this->AnInt = NewABC->AnInt;
-
- why the ->? should be: AAnInt = NewABC.AnInt;
- >}
- >
- >Unfortunatly, I can't get this to work right. I get weird messages from
- >the compiler complaining about not being able to use a class definition
- >as an argument. This was using xlC under IBM Aix. Any suggestions are
- >greatly appreciated. Thanks.
- >
- >
- > T E A R A L O N G T H E D O T T E D L I N E
- >- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- >Corby S. Hudnall Junior, Spring 1996
- >Colorado State University http://WWW.CS.ColoState.EDU/~hudnall
- >Department of Computer Science hudnall@CS.ColoState.EDU
- >
- >
-
-